package com.dingli.controller;

import com.dingli.framework.entity.Enterprise;
import com.dingli.framework.entity.Member;
import com.dingli.framework.mapper.EnterpriseMapper;
import com.dingli.framework.util.Encryption;
import com.dingli.framework.util.Response;
import com.dingli.service.IEnterpriseService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

@CrossOrigin("*")
@RestController
@RequestMapping("/enterprise")
@Api(tags = "会员企业")
public class EnterpriseController {

    @Autowired
    private IEnterpriseService iEnterpriseService;

    @GetMapping("/Eslist")
    @ApiOperation("会员企业信息列表查询")
    public Response<PageInfo<Enterprise>> Eslist(@ApiParam("查询条件")
                                             @RequestParam(required = false) String search,
                                             @ApiParam("页码") @RequestParam(required = false) Integer pageNum,
                                             @ApiParam("页面大小")
                                             @RequestParam(required = false) Integer pageSize) {
        return iEnterpriseService.Eslist(search, pageNum, pageSize);
    }

    @PostMapping("/Eseinsert")
    @ApiOperation("会员企业信息新增")
    public Object Eseinsert(@ApiParam("会员企业信息") @RequestBody Enterprise enterprise) {

        return iEnterpriseService.Eseinsert(enterprise);
    }

    @GetMapping("/EseselectById")
    @ApiOperation("会员企业信息详情查看")
    public Response<Enterprise> EseselectById(@ApiParam("会员企业ID") @RequestParam Long eseId) {
        return iEnterpriseService.EseselectById(eseId);
    }

    @PostMapping("/EseupdateById")
    @ApiOperation("会员企业信息修改")
    public Response<Object> EseupdateById(@ApiParam("修改的会员企业信息") @RequestBody Enterprise enterprise) {

        return iEnterpriseService.EseupdateById(enterprise);
    }

    @GetMapping("/EsedeleteById")
    @ApiOperation("会员企业信息删除")
    public Response<Object> EsedeleteById(@ApiParam("会员企业ID") @RequestParam Long eseId) {
        return iEnterpriseService.EsedeleteById(eseId);
    }

    /*@RequestMapping ("/slectArea")
    @CrossOrigin
    @ApiOperation("会员多条件模糊查询")
    public Response<List<Member>> selectArea(@ApiParam("会员地区,职位检索") @RequestParam String mbEseprovince){
        return iMemberService.selectArea(mbEseprovince);
    }*/

    /*@RequestMapping ("/selectName")
    @CrossOrigin
    @ApiOperation("会员企业名称模糊查询")
    public Response<List<Member>> selectName(@ApiParam("企业名称检索") @RequestParam String mbCompany){
        return iMemberService.selectName(mbCompany);
    }*/

    @PostMapping("/EseupdateState")
    @ApiOperation("会员企业审核")
    public Response<Object> EseupdateState(@ApiParam("审核会员企业通过") @RequestBody String eseId) {
        return iEnterpriseService.EseupdateState(eseId);
    }

    @PostMapping("/Eseupdate")
    @ApiOperation("会员企业审核")
    public Response<Object> Eseupdate(@ApiParam("审核会员企业不通过") @RequestBody String eseId) {

        return iEnterpriseService.Eseupdate(eseId);
    }

    @RequestMapping ("/EseselectState")
    @CrossOrigin
    @ApiOperation("审核查询")
    public HashMap<Object, Object> EseselectState(@ApiParam("审核中查询") @RequestParam String eseState){
        Response<List<Enterprise>> list = iEnterpriseService.EseselectState(eseState);
        HashMap<Object, Object> ob = new HashMap<>();
        ob.put("Enterprise",list);
        ob.put("size",list.getData().size());
        return ob;
    }

    @RequestMapping ("/EseselectState1")
    @CrossOrigin
    @ApiOperation("审核查询")
    public  HashMap<Object, Object> EseselectState1(@ApiParam("审核通过查询") @RequestParam String eseState){
        Response<List<Enterprise>> list = iEnterpriseService.EseselectState1(eseState);
        HashMap<Object, Object> yy = new HashMap<>();
        yy.put("Enterprise",list);
        yy.put("size",list.getData().size());
        return yy;
    }

    @RequestMapping ("/EseAll")
    @CrossOrigin
    @ApiOperation("会员企业统计")
    public HashMap<Object, Object> EseAll(@ApiParam("会员统计") @RequestParam String eseId){
        Response<List<Enterprise>> list = iEnterpriseService.EseAll(eseId);
        HashMap<Object, Object> yy = new HashMap<>();
//        wh.put("Enterprise",list);
        yy.put("size",list.getData().size());
        return yy;
    }
}
